﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BestBuy.DAL;
namespace BestBuy.PageUser
{
    public partial class ViewCompanyaspx : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadInfoCompany();
        }
        private void LoadInfoCompany()
        {
            int idCompany = CCongTy.getIdCompany(int.Parse(Session["IDDN"].ToString()));
            CongTy ct = CCongTy.getInfo(idCompany);
            liCompanyName.Text = ct.TenCongTy;
            liBusiness.Text = ct.LoaiCongTy;
            String[] main = ct.ThiTruongChinh.Split('+');
            for (int i = 0; i < ChecklistMarket.Items.Count - 1; i++)
            {
                if (main[i] == "1")
                {
                    ChecklistMarket.Items[i].Selected = true;
                }
            }
            liIndustry.Text= ct.IDNganh.ToString();
            txtKeyProduct.Text = ct.TuKhoaSanPham;
            List<DanhMucCongTy> listct = CCongTy.getAllCategoryCompany(idCompany);
            for (int i = 0; i < listct.Count; i++)
            {
                ListItem item = new ListItem();
                DanhMuc dm = CCongTy.getItem(listct[i].IDDanhMuc);
                item.Value = dm.IDDanhMuc.ToString();
                item.Text = dm.TenDanhMuc;
                CategoryListBox.Items.Add(item);
            }
            liEmployees.Text = ct.SoLuongNhanVien;
           liYear.Text = ct.NamThanhLap.ToString();
            txtIntroduct.Text = ct.GioiThieuCongTy;
            liWebsite.Text = ct.TrangCongTy;
            if (ct.LogoCongTy != null)
            {
                ImageLogo.Visible = true;
                ImageLogo.ImageUrl = "~/Images/Product/" + ct.LogoCongTy;                
            }
            liBrochoure.Text = ct.TaiLieu;
            liFactoryLocation.Text = ct.KhuVucNhaMay;
            if (ct.KichThuocNhaMay != null)
            {
                liFactorySize.Text = ct.KichThuocNhaMay;
            }
            if (ct.TongSoBanHangNam != null)
            {
                liTotalAnnual.Text = ct.TongSoBanHangNam;
            }
            if (ct.SoLuongNhanVienRD != null)
            {
                liRD.Text = ct.SoLuongNhanVienRD;
            }
            if (ct.SoLuongNhanVienQC != null)
            {
                liQC.Text = ct.SoLuongNhanVienQC;
            }
            liCertificate.Text = ct.GiayChungNhan;
            if (ct.HopDongSanXuat != null)
            {
                String[] strHD = ct.HopDongSanXuat.Split('+');
                for (int i = 0; i < CheckBoxListContract.Items.Count - 1; i++)
                {
                    if (strHD[i] == "1")
                    {
                        CheckBoxListContract.Items[i].Selected = true;
                    }
                }
            }
            if (ct.VonDieuLe != null)
            {
                liCapital.Text = ct.VonDieuLe;
            }
            if (ct.LoaiQuyenSoHuu != null)
            {
                liOwnership.Text = ct.LoaiQuyenSoHuu;
            }
            if (ct.NguoiDaiDien != null)
            {
                liLegal.Text = ct.NguoiDaiDien;
            }
            if (ct.TongSoBanHangNam != null)
            {
                liTotalAnnualSale.Text = ct.TongSoBanHangNam;
            }
            if (ct.TyLeXuatKhau != null)
            {
                liExport.Text = ct.TyLeXuatKhau;
            }
        }
    }
}